#include "MyGame.hpp"

MyGame::MyGame(Engine* engine) : m_engine(engine)
{
	m_balls.push_back( Ball(Vector(0), Vector(0.02, 0.016)) );
}

void MyGame::onTick()
{
	//std::cout << "Tick\n";
	
	for( BallIterator iter=m_balls.begin();
		 iter!=m_balls.end();
		 ++iter ) {
		iter->interact();
		iter->update();
	}
	
}

void MyGame::onFrame(IRenderer* caller)
{
	glBegin(GL_LINES);
	glColor4f(1.f, 0.f, 0.f, 1.f);
	glVertex2f(0.f, 0.f);
	glVertex2f(1.f, 0.f);
	glColor4f(0.f, 1.f, 0.f, 1.f);
	glVertex2f(0.f, 0.f);
	glVertex2f(0.f, 1.f);
	glEnd();
	
	for( BallIterator iter=m_balls.begin();
		 iter!=m_balls.end();
		 ++iter ) {
		iter->draw();
	}
	
	/*
	const size_t N = 100;
	for( size_t y=0; y<N; ++y ) {
		for( size_t x=0; x<N; ++x ) {
			glPushMatrix();
			glTranslatef(-0.5+(float)x/N, -0.5+(float)y/N, 0.0);
			glScalef(0.1/N, 0.1/N, 1.0);
			glBegin(GL_QUADS);
			glColor4f(1.f, 1.f, 1.f, 1.f);
			glVertex2f(-1.f, -1.f);
			glVertex2f(-1.f, 1.f);
			glVertex2f(1.f, 1.f);
			glVertex2f(1.f, -1.f);
			glEnd();
			glPopMatrix();
		}
	}
	*/
}

